import request from 'utils/request';

// 1.定义获取文章列表Api
export function getArticleAPI(params){
    return request({
        url:'/v1_0/mp/articles',
        params
    })
}

// 2.删除文章Api
export function delArticleAPI(id){
    return request({
        url:`/v1_0/mp/articles/${id}`,
        method: 'DELETE'
    })
}

// 3.发布文章Api(改造API的draft)
export function publicArticleAPI(data,draft=false){
    return request({
        url:`/v1_0/mp/articles?draft=${draft}`,
        method: 'post',
        data
    })
}

// 2. API封装
export const getArticleById = (id) => {
    return request({
      url: `/v1_0/mp/articles/${id}`,
      method: 'get',
    });
  };

  // 3.编辑文章Api(改造API的draft)
  export const editArticleAPI = (data, draft = false) => {
    return request({
      url: `/v1_0/mp/articles/${data.id}?draft=${draft}`,
      method: 'put',
      data,
    });
  };